package com.wefans.wefansapp.activity;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.wefans.wefansapp.R;
import com.wefans.wefansapp.common.tool.data.BenefitUserData;
import com.wefans.wefansapp.common.tool.data.BenefitUserResponseWinData;
import com.wefans.wefansapp.common.tool.debug.MFDebug;


public class BenefitUserAdaptor extends ArrayAdapter<BenefitUserResponseWinData> {

	private Context                                m_ctx         = null;                           
    private int                                    m_nResID      = -1;
    private ArrayList<BenefitUserResponseWinData>   		   m_alsItems    = null;
    private LayoutInflater                         m_inflater    = null;

	public BenefitUserAdaptor(Context ctx, int nResID, ArrayList<BenefitUserResponseWinData> mBenefitUserItems) {
        super(ctx, nResID, mBenefitUserItems);
        MFDebug.d(">> NMHistoryAdapter::NMNoticeAdapter(ctx, nResID, aylsItems) ");
        this.m_ctx       = ctx;
        this.m_nResID    = nResID;
        this.m_alsItems  = mBenefitUserItems;
        this.m_inflater  = (LayoutInflater)m_ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		MFDebug.d(">> Benefit::getView()");
		MFDebug.d("++ position=" + position);
		MFDebug.d("++ convertView=" + convertView);
        MFDebug.d("++ parent=" + parent);

        final BenefitUserResponseWinData dBenefitUserData = m_alsItems.get(position);

        ViewHolder vh = null;
        
		if (convertView == null) {
			convertView = m_inflater.inflate(m_nResID, null);
			vh = new ViewHolder();
			vh.tvUserNo 	= (TextView) convertView.findViewById(R.id.TV_BENEFIT_USER_NO);
			vh.tvUserName 	= (TextView) convertView.findViewById(R.id.TV_BENEFIT_USER_NAME);
			convertView.setTag(vh);
		}
        else
        {
            vh = (ViewHolder) convertView.getTag();
        }
		
		vh.tvUserName.setText(dBenefitUserData.getNickname());
		vh.tvUserNo.setText(String.valueOf(position));
		
        return convertView;
    }
    
    public class ViewHolder
    {
    	TextView  tvUserNo  	= null;
    	TextView  tvUserName  	= null;
    }
}